package cn.szv5;

/**
 * @ClassName NameNode
 * @Description NameNode核心启动类
 * @Author Carl
 * @Company: 阿飞工作室(https : / / szv5.cn)
 * @Date 2022/3/1 20:07
 * @Version 1.0
 **/
public class NameNode {

    /**
     * NameNode是否在运行
     */
    private volatile boolean shouldRun;

    /**
     * 负责管理元数据的核心组件
     */
    private FSNamesystem fsNamesystem;

    /**
     * NameNode对外提供rpc接口的server,可以响应请求
     */
    private NameNodeRpcServer nameNodeRpcServer;

    public NameNode() {
        this.shouldRun = true;
    }
    private void initialize() {
        fsNamesystem = new FSNamesystem();
        nameNodeRpcServer = new NameNodeRpcServer(fsNamesystem);
        nameNodeRpcServer.start();
    }

    private void run(){
        try {
            while (shouldRun) {
                Thread.sleep(1000);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        NameNode nameNode = new NameNode();
        nameNode.initialize();
        nameNode.run();
    }
}
